package warmachineroster.grapheditor.command;

import org.eclipse.gef.commands.Command;

import warmachineroster.RosterElement;
import warmachineroster.UnitRosterElement;

public class UnitAttachmentRosterElementMoveCommand extends Command {

	private int newIndex;
	private int oldIndex;
	private RosterElement unitAttachmentRosterElement;
	private UnitRosterElement unitRosterElement;

	public void setNewIndex(int newIndex) {
		this.newIndex = newIndex;
	}

	public void setOldIndex(int oldIndex) {
		this.oldIndex = oldIndex;

	}

	public void setUnitAttachmentRosterElement(RosterElement childModel) {
		this.unitAttachmentRosterElement = childModel;
	}

	public void setUnitRosterElement(
			UnitRosterElement unitRosterElement) {
		this.unitRosterElement = unitRosterElement;
	}

	@Override
	public void execute() {
		unitRosterElement.getUnitAttachment().remove(unitAttachmentRosterElement);
		unitRosterElement.getUnitAttachment().add(newIndex, unitAttachmentRosterElement);
	}

	@Override
	public void undo() {
		unitRosterElement.getUnitAttachment().remove(unitAttachmentRosterElement);
		unitRosterElement.getUnitAttachment().add(oldIndex, unitAttachmentRosterElement);
	}

	
	
}
